// generated 2005/8/1 13:00:51 CST by xihels@163.com
//


#ifndef _MSGBOX_HH
#  define _MSGBOX_HH
#include <gtkmm/image.h>
#include <string>
using std::string;
#include <gtkmm/textview.h>
#include "TagList.h"
#include <functional>
#include "QQSession.h"
using std::unary_function;

class MsgBox : public Gtk::TextView
{
    public:
	typedef Glib::RefPtr<Gtk::TextBuffer::TagTable> RefTagTable;
	typedef Glib::RefPtr<Gtk::TextTag> RefTag;
	
	MsgBox();

	void showMessage(const string& text);
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	///void showMessage(const string& message);//merged together.

	void showMessage(string::const_iterator first, string::const_iterator last);
	void showSmiley(int index) { insertSmiley(index, true); }
	string::const_iterator getCustomSmil(string::const_iterator index);
	void showSimpleText(const string & text);//original text output with out encode to UTF-8
	struct isSmile : public unary_function<char, bool> {
	    bool operator ()(char ch) const 
	    {
		return 
		    (QQ_DEFAULT_FACE_TAG == ch) ||
		    (QQ_CUSTOM_FACE_TAG == ch);
	    }
	};
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	void insertPixbuf(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf);
	void insertImage(Gtk::Image* image);
	void insertSmiley(int index, bool isend = false);
	
	void clear();
	void getText(Glib::ustring&);

	void showTitle(const string& sender, uint32_t senderid, uint32_t time)
	{
	    RefTag titlecolor = taglist.getTitleColor(senderid);    
	    showTitle(sender, titlecolor, time);
	}

	void showTitle(const string& sender, uint32_t time)
	{
	    RefTag titlecolor = taglist.getSelfTitleColor();    
	    showTitle(sender, titlecolor, time);
	}

    private:
	void showTitle(const string& sender, RefTag titlecolor, uint32_t time);
	TagList taglist;

};
#endif
